/*
 * @Author: your name
 * @Date: 2021-09-09 20:53:54
 * @LastEditTime: 2021-11-20 10:52:02
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /blogServe/src/service/auth.service.js
 */
const connection = require('../app/database');

// 判断是否具备权限
class AuthService {
  // 查看是否具备修改动态权限
  async checkMoment(momentId, userId) {
    // return false;
    try {
      console.log("判断是否具备权限");
      const statement = `SELECT * FROM moment WHERE id = ? AND user_id = ?;`;
      const[result] = await connection.execute(statement, [momentId, userId]);
      return result.length === 0 ? false : true;
    } catch(error) {
      console.log(error);
    }
  }
}

module.exports = new AuthService();
